/**
 * 
 */
package com.google.code.cisx.ann.processor;

import com.google.code.cisx.ann.DTO;
import com.google.code.cisx.ann.DTO.PropertyGenerationStrategy;

import java.util.Iterator;
import java.util.Set;

import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.RoundEnvironment;
import javax.annotation.processing.SupportedAnnotationTypes;
import javax.annotation.processing.SupportedSourceVersion;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.Element;
import javax.lang.model.element.Modifier;
import javax.lang.model.element.TypeElement;

/**
 * @author <a href='mailto:rahul.thakur.xdev@gmail.com'>Rahul Thakur</a>
 * @since 1.0
 * @version $Id: DTOProcessor.java 258 2008-11-29 06:23:51Z rahul.thakur.xdev $
 */
@SupportedAnnotationTypes(value = {"com.google.code.cisx.ann.DTO"})
@SupportedSourceVersion(SourceVersion.RELEASE_5)
public class DTOProcessor extends AbstractProcessor {

  /**
   * {@inheritDoc}
   * 
   * @see javax.annotation.processing.AbstractProcessor#process(java.util.Set,
   *      javax.annotation.processing.RoundEnvironment)
   */
  @Override
  public boolean process(Set<? extends TypeElement> annotations,
      RoundEnvironment roundEnv) {
    for (TypeElement te : annotations) {
      for (Element e : roundEnv.getElementsAnnotatedWith(te)) {
        DTO dto = e.getAnnotation(DTO.class);
        PropertyGenerationStrategy strategy = dto.strategy();

        String klass = e.getEnclosingElement().toString();
        System.out.println("Generating DTO for Model class: " + klass);
        System.out.println(strategy.toString());
        for (Modifier m : e.getModifiers()) {
          System.out.println(m.toString());
        }
        System.out.println(e.getSimpleName());

        // End
        System.out.println("\n");
      }

    }
    return false;
  }
}
